package com.jky.stmall.front.mapper;

import com.jky.stmall.front.entity.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {
    //只查询一级分类
    @Select({"select * from category",
    "where parent_id is null",
    "and status =0",})
    @Results({
            @Result(column = "id",property = "id",id=true),
            @Result(column="id",property="children",
            many=@Many(select="selectByParentId"))
    })
    List<Category> selectParent();

    //根据父类
    @Select({"select * from category",
            "where parent_id=#{parentId}",
            "and status =0",})

    List<Category> selectByParentId(Integer parentId);
}
